<!DOCTYPE html>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j">

    <h:form id="form_edit_product">

        <ui:repeat value="#{productc.productb.product.productPictures}" var="pp">
            <h:graphicImage  value="#{pp.picture}" height="75" width="75" />
        </ui:repeat>
                    
        <h:panelGrid columns="3">

            <h:outputLabel for="status" value="Produto:" />
            <h:selectOneMenu id="status" value="#{productc.productb.product.status}" converter="#{statusConverter}" validator="statusValidator">
                <f:selectItems value="#{utila.status}" var="status" itemValue="#{status.id}" itemLabel="#{status.status}" />
                <f:ajax event="blur" render="m_status" />
            </h:selectOneMenu>
            <rich:message id="m_status" for="status" />

            <h:outputLabel for="operation" value="Operação:" />
            <h:selectOneMenu id="operation" value="#{productc.productb.product.operation}" converter="#{operationConverter}" validator="operationValidator">
                <f:selectItems value="#{utila.operations}" var="operation" itemValue="#{operation.id}" itemLabel="#{operation.operation}" />
                <f:ajax event="blur" render="m_operation" />
            </h:selectOneMenu>
            <rich:message id="m_operation" for="operation" />

            <h:outputLabel for="name" value="Nome:" />
            <h:inputText id="name" value="#{productc.productb.product.name}">
                <f:ajax event="blur" listener="#{pv.name}" render="m_name" />
            </h:inputText>
            <rich:message id="m_name" for="name" ajaxRendered="false" />

            <h:outputLabel for="quantity" value="Quantidade:" />
            <h:inputText id="quantity" value="#{productc.productb.product.quantity}" converterMessage="somente números" size="7" maxlength="7">
                <f:convertNumber minIntegerDigits="1" maxIntegerDigits="7" />
                <f:ajax event="blur" listener="#{pv.quantity}" render="m_quantity" />
            </h:inputText>
            <rich:message id="m_quantity" for="quantity" ajaxRendered="false" />

            <h:outputLabel for="measure" value="Unidade:" />
            <h:selectOneMenu id="measure" value="#{productc.productb.product.measure}" converter="#{measureConverter}" validator="measureValidator">
                <f:selectItems value="#{utila.measures}" var="measure" itemValue="#{measure.id}" itemLabel="measure.measure" />
                <f:ajax event="blur" render="m_measure" />
            </h:selectOneMenu>
            <rich:message id="m_measure" for="measure" />

            <h:outputLabel for="state" value="Estado:" />
            <h:selectOneMenu id="state" value="#{productc.productb.product.location.state}" converter="#{stateConverter}" validator="stateValidator">
                <f:selectItems value="#{utila.states}" var="state" itemValue="#{state.id}" itemLabel="state.state" />
                <f:ajax event="blur" listener="#{pv.state}" render="m_state" />
            </h:selectOneMenu>
            <rich:message id="m_state" for="state" />

            <h:outputLabel for="city" value="Cidade:" />
            <h:inputText id="city" value="#{productc.productb.product.location.city.city}">
                <f:ajax event="blur" listener="#{pv.city}" render="m_city" />
            </h:inputText>
            <rich:message id="m_city" for="city" ajaxRendered="false" />

            <h:outputLabel for="locale" value="Local:" />
            <h:inputText id="locale" value="#{productc.productb.product.location.locale}">
                <f:ajax event="blur" listener="#{pv.locale}" render="m_locale" />
            </h:inputText>
            <rich:message id="m_locale" for="locale" ajaxRendered="false" />

        </h:panelGrid>

        <h:panelGrid>
            <h:outputLabel for="description" value="Descrição do produto:" />
            <h:inputTextarea id="description" value="#{productc.productb.product.description}" cols="50" rows="10">
                <f:ajax event="blur" listener="#{pv.description}" render="m_description" />
            </h:inputTextarea>
            <rich:message id="m_description" for="description" ajaxRendered="false" />
        </h:panelGrid>

        <h:commandButton value="Atualizar" action="#{productc.update}" />
    </h:form>


</ui:composition>		